<form class="layui-form" action="">

  <div class="layui-form-item">
    <label class="layui-form-label">上级类目</label>
    <div class="layui-input-inline">
      <select name="pid" lay-verify="required">
        <option value="0">一级类目</option>
        {notempty name='list'}
        {foreach $list as $k=>$v}
        <option value="{$v.id}" {present name="info"}{eq name="info.pid" value="$v.id"}selected{/eq}{/present}>{$v.name}</option>
        {/foreach}
        {/notempty}
      </select>
    </div>
  </div>
    <div class="layui-form-item">
    <label class="layui-form-label">名称</label>
    <div class="layui-input-inline">
      <input type="text" name="name" required lay-verify="required" placeholder="请输入名称" autocomplete="off" class="layui-input" value="{present name="info"}{$info.name}{/present}">
    </div>
    <div class="layui-form-mid layui-word-aux"></div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">排序</label>
    <div class="layui-input-inline">
      <input type="text" name="sort" required lay-verify="required" placeholder="数字升序" autocomplete="off" class="layui-input" value="{present name="info"}{$info.sort}{/present}">
    </div>
    <div class="layui-form-mid layui-word-aux"></div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">状态</label>
    <div class="layui-input-block">
      <input type="checkbox" name="status" lay-skin="switch" lay-text="开启|关闭" value="1" {present name="info"}{eq name="info.status" value="1"}checked{/eq}{/present}>
    </div>
  </div>
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="sub">立即提交</button>
    </div>
  </div>
</form>
 
<script>
//Demo
layui.use('form', function(){
  var form = layui.form;
  
  //监听提交
  form.on('submit(sub)', function(data){
    $.post("",data.field,function(info){
        if(info.code){
            layer.msg(info.msg);
            setTimeout(function(){
                    var index = parent.layer.getFrameIndex(window.name);//获取父层
                    parent.location.reload();//刷新父层
                    parent.layer.close(index);//关闭弹出层 
                },2000);
        }else{
            layer.msg(info.msg);
        }
    });
    return false;
  });
});
</script>